package com.yanfei.zero.apis;

import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.yanfei.zero.infrastructure.mq.MqProducer;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

@Tag(name="支付相关")
@RestController
public class PayController {
	@Resource
	private MqProducer mqProducer;
	
	@Operation(summary = "微信支付")
    @GetMapping(path = "wxPay")
    public void sendMsg(@RequestParam(name = "msg") String msg, @RequestParam(name = "routingKey") String routingKey) throws Exception {

    }
	
	@Operation(summary = "微信转账")
    @GetMapping(path = "wxTransfer")
    public void wxTransfer(@RequestParam(name = "msg") String msg, @RequestParam(name = "routingKey") String routingKey) throws Exception {

    }
    @Operation(summary = "微信提现")
    @GetMapping(path = "wxWithdraw")
    public void wxWithdraw(@RequestParam(name = "msg") String msg, @RequestParam(name = "routingKey") String routingKey) throws Exception {

    }
    @Operation(summary = "微信退款")
    @GetMapping(path = "wxRefund")
    public void wxRefund(@RequestParam(name = "msg") String msg, @RequestParam(name = "routingKey") String routingKey) throws Exception {

    }
    @PostMapping("/notifyMnp")
    @Operation(summary="微信支付回调")
    public void  notifyMnp(@RequestBody String jsonData, HttpServletRequest request) throws WxPayException {
        // 构建签名
        SignatureHeader signatureHeader = new SignatureHeader();
        signatureHeader.setSignature(request.getHeader("wechatpay-signature"));
        signatureHeader.setNonce(request.getHeader("wechatpay-nonce"));
        signatureHeader.setSerial(request.getHeader("wechatpay-serial"));
        signatureHeader.setTimeStamp(request.getHeader("wechatpay-timestamp"));
    }

    @Operation(summary = "支付宝支付")
    @GetMapping(path = "zfbPay")
    public void zfbPay(@RequestParam(name = "msg") String msg, @RequestParam(name = "routingKey") String routingKey) throws Exception {

    }
	

}
